<!-- 个人中心 -->
<template>
	<view class="container">
		<view style="display: flex;">
			<view style="width: 200rpx;height: 200rpx;">
				<image style="width: 200rpx;height: 200rpx;" :src="detail.img_main" mode="widthFix"></image>
			</view>
			<view style="margin-left: 20rpx;">
				<view style="color: #333333;font-size: 36rpx;font-weight: bold;">{{detail.user_name}}</view>
				<view style="color: #999999;font-size: 28rpx;margin-top: 20rpx;">{{detail.title?detail.title:''}}</view>
			</view>
		</view>
		
		<view style="margin:20rpx 0;" >
				<u-parse :html="detail.info" :tag-style="vuex_parse_style" :domain="'https://huboshizb.bigchun.com'"
				 @linkpress="diylinkpress"></u-parse>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				detail: null,
				id: null
			}
		},
		filters: {
			dateFormat(time) {
				let date = new Date(time * 1000);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				// return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				return year + "年" + month + "月" + day + "日";
			},
		},
		onLoad(options) {
			console.log(options);
			this.id = options.id;
			this.trainDetail()
		},
		onShow() {
			console.log('111111')
		},
		computed: {

		},
		methods: {
			trainDetail() {
				this.$api.trainDetail({
					id: this.id
				}).then(res => {
					console.log('trainDetail', res)
					if (res.code == 1) {
						// if(res.data.info){
						// 	res.data.info = res.data.info.replace(/<[^>]+>/g,"");
						// }
						
						this.detail = res.data;
						uni.setNavigationBarTitle({
							title: res.data.user_name + "个人简介"
						});
					}
				});
			}
		},
		onUnload() {}
	}
</script>

<style lang="scss" scoped>
	.container {
		margin: 20rpx;
	}
</style>